package 力扣;

import java.util.Arrays;

public class 反转字符串344 {
    public static void reverseString(char[] s) {
        int mm=(s.length-1)/2;
        int mid=mm;
        char p;
        if (mm%2==0){
            while (mid!=0){
                mid++;
                p=s[mm-mid];
                s[mid-mid]=s[mm+mid];
                s[mid+mm]=p;
            }
        }
        else{
            while (mid!=0){
                while (mid!=0)
                {
                    mid--;
                    p=s[mid+1];
                    s[mid+1]=s[mid];
                    s[mid]=p;
                }
            }
        }
    }
    public static void reverseString2(char[] s) {
        int m=0;
        for (int i =s.length-1; i >=s.length/2 ; i--) {
            m=s.length-1-i;
            char p;
            p=s[m];
            s[m]=s[i];
            s[i]=p;
        }
    }

    public static void main(String[] args) {
        char []s={'h','e','l','l','o'};
        char []s2={'H','a','n','n','a','h'};
        reverseString2(s2);
        System.out.println(Arrays.toString(s2));
    }
}
